// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed class MlStopDatafeedRequestParameters : RequestParameters<MlStopDatafeedRequestParameters>
	{
	}

	public sealed partial class MlStopDatafeedRequest : PlainRequestBase<MlStopDatafeedRequestParameters>
	{
		public MlStopDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeed_id) : base(r => r.Required("datafeed_id", datafeed_id))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningStopDatafeed;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("allow_no_match")]
		public bool? AllowNoMatch { get; set; }

		[JsonInclude]
		[JsonPropertyName("force")]
		public bool? Force { get; set; }

		[JsonInclude]
		[JsonPropertyName("timeout")]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get; set; }
	}

	public sealed partial class MlStopDatafeedRequestDescriptor : RequestDescriptorBase<MlStopDatafeedRequestDescriptor, MlStopDatafeedRequestParameters>
	{
		internal MlStopDatafeedRequestDescriptor(Action<MlStopDatafeedRequestDescriptor> configure) => configure.Invoke(this);
		public MlStopDatafeedRequestDescriptor(Elastic.Clients.Elasticsearch.Id datafeed_id) : base(r => r.Required("datafeed_id", datafeed_id))
		{
		}

		internal MlStopDatafeedRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningStopDatafeed;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlStopDatafeedRequestDescriptor DatafeedId(Elastic.Clients.Elasticsearch.Id datafeed_id)
		{
			RouteValues.Required("datafeed_id", datafeed_id);
			return Self;
		}

		private bool? AllowNoMatchValue { get; set; }

		private bool? ForceValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? TimeoutValue { get; set; }

		public MlStopDatafeedRequestDescriptor AllowNoMatch(bool? allowNoMatch = true)
		{
			AllowNoMatchValue = allowNoMatch;
			return Self;
		}

		public MlStopDatafeedRequestDescriptor Force(bool? force = true)
		{
			ForceValue = force;
			return Self;
		}

		public MlStopDatafeedRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? timeout)
		{
			TimeoutValue = timeout;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AllowNoMatchValue.HasValue)
			{
				writer.WritePropertyName("allow_no_match");
				writer.WriteBooleanValue(AllowNoMatchValue.Value);
			}

			if (ForceValue.HasValue)
			{
				writer.WritePropertyName("force");
				writer.WriteBooleanValue(ForceValue.Value);
			}

			if (TimeoutValue is not null)
			{
				writer.WritePropertyName("timeout");
				JsonSerializer.Serialize(writer, TimeoutValue, options);
			}

			writer.WriteEndObject();
		}
	}
}